import { IPSWFCallOrgActivityProcess } from './ipswfcall-org-activity-process';
import { IPSWFProcessRole } from './ipswfprocess-role';
import { IPSWorkflow } from './ipsworkflow';
import { PSWFProcessImpl } from './pswfprocess-impl';

export class PSWFCallOrgActivityProcessImpl extends PSWFProcessImpl implements IPSWFCallOrgActivityProcess {
  get multiInstMode(): 'NONE' | 'PARALLEL' | 'SEQUENTIAL' {
    return this.M.multiInstMode || 'NONE';
  }

  protected pswfprocessroles: IPSWFProcessRole[] | null = null;

  getPSWFProcessRoles(): IPSWFProcessRole[] | null {
    if (this.pswfprocessroles == null) {
      this.pswfprocessroles = this.fillChildListModel(this.M.getPSWFProcessRoles, 'wf.IPSWFProcessRole') as IPSWFProcessRole[];
    }
    return this.pswfprocessroles;
  }

  get psWFProcessRoles(): IPSWFProcessRole[] | null {
    return this.getPSWFProcessRoles();
  }

  findPSWFProcessRole(objKey: any): IPSWFProcessRole | null {
    return this.getPSModel5('wf.IPSWFProcessRole', this.getPSWFProcessRoles(), objKey) as IPSWFProcessRole;
  }

  protected tarpswf: IPSWorkflow | null = null;

  getTargetPSWF(): IPSWorkflow | null {
    if (this.tarpswf != null) return this.tarpswf;
    const value = this.M.getTargetPSWF;
    if (value == null) {
      return null;
    }
    this.tarpswf = this.getPSModel4('wf.IPSWorkflow', value, 'getTargetPSWF') as IPSWorkflow;
    return this.tarpswf;
  }

  get targetPSWF(): IPSWorkflow | null {
    return this.getTargetPSWF();
  }

  getTargetPSWFMust(): IPSWorkflow {
    const value = this.getTargetPSWF();
    if (value == null) {
      throw new Error('未指定调用目标流程');
    }
    return value;
  }

  get cls(): string {
    return 'PSWFCallOrgActivityProcessImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWFCallOrgActivityProcess') return true;
    return super.instanceof(cls);
  }
}
